package com.test.learnkotlin

/**
 *Author: chinadragon
 *Time: 2024/3/11 09:31
 */

open class Rectangle1 {
    open fun draw() { println("Drawing a rectangle1") }
    val borderColor: String get() = "black"
}

class FilledRectangle1 : Rectangle1() {
    override fun draw() {
        super.draw()
        println("Filling the rectangle1")
    }

    val fillColor: String get() = super.borderColor
}

class FilledRectangle2: Rectangle1() {
    override fun draw() {
        val filler = Filler1()
        filler.drawAndFill()
    }

    inner class Filler1 {
        fun fill() { println("Filling") }
        fun drawAndFill() {
            super@FilledRectangle2.draw() // 调用 Rectangle1 的 draw() 实现
            fill()
            println("Drawn a filled rectangle with color ${super@FilledRectangle2.borderColor}") // 使用 Rectangle1 所实现的 borderColor 的 get()
        }
    }
}


fun main(){
    val filledRectangle2 = FilledRectangle2()
    filledRectangle2.draw()
}
